import { useSettingsStore } from "@/stores/settings.ts"
import { generateColors, setColors } from "@/utils/color.ts"

export const useGenerateTheme = () => {
  // 监控主题变化 存入store
  // 获取主题
  const store = useSettingsStore()
  const theme = computed(() => store.settings.theme)
  const originalThem = computed(() => store.settings.originalThem)

  watchEffect(() => {
    if (theme.value !== originalThem.value) {
      const colors = {
        primary: theme.value,
        ...generateColors(theme.value)
      }
      setColors(colors)
      store.changeSetting({ key: "originalThem", value: theme.value })
    }
  })
}
